{% extends "base.html" %}
{% block title %}<title>创建项目-消防系统计算平台</title>{% endblock %}
{% block extrastyle %}
    {% load static %}
    <style type="text/css">
        .col-lg-3 {
            text-align: right;
        }
    </style>
{% endblock %}
{% block header %}
    {% include "header.html" %}
    {% include "select_module.html" %}
{% endblock %}

{% block content %}
    <div class="content">
        <form method="post" id="form">
            {% csrf_token %}
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>项目名称<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="project_name" name="project_name"
                                   value="" placeholder="请输入项目名称"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>项目编号<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="project_num" name="project_num"
                                   value="" placeholder="请输入项目编号"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>项目概况<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                        <textarea type="text" class="form-control" id="project_text" name="project_text" rows="5"
                                  placeholder="请输入项目概况"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>设计人<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="designer" name="designer" value=""
                                   placeholder="请输入项目设计人"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>校对人<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="proofreader" name="proofreader"
                                   value="" placeholder="请输入项目校对人"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>专业负责人<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="chief" name="chief" value=""
                                   placeholder="请输入专业负责人"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>审批人<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="approver" name="approver" value=""
                                   placeholder="请输入审批人"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group">
                        <div class="col-lg-3"><label>版本号<span style="color:red">*</span>：</label></div>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="version" name="version" value=""
                                   placeholder="请输入版本号"/>
                        </div>
                    </div>
                </div>
            </div>
            <h3>选择项目模块：</h3>
            <div class="row" style="margin-bottom:10px">
                <div class="col-lg-4">
                    <div class="input-group">
			 <span class="input-group-addon">
				 <input type="checkbox" name="{{ module_list.0.module_en_name }}"
                        id="{{ module_list.0.module_en_name }}">
			 </span>
                        <input type="text" class="form-control" disabled value="{{ module_list.0.module_name }}">
                    </div>
                </div>
                <div class="col-lg-3">
                    <div class="input-group">
				 <span class="input-group-addon">
					 <input type="checkbox" name="{{ module_list.1.module_en_name }}"
                            id="{{ module_list.1.module_en_name }}" >
				 </span>
                        <input type="text" class="form-control" disabled value="{{ module_list.1.module_name }}">
                    </div>
                </div>

                <div class="col-lg-5">
                    <div class="input-group">
				<span class="input-group-addon">
					<input type="checkbox" name="{{ module_list.2.module_en_name }}"
                           id="{{ module_list.2.module_en_name }}">
				</span>
                        <input type="text" class="form-control" disabled value="{{ module_list.2.module_name }}">

                        <span class="input-group-addon">
					<input type="checkbox" name="hydrant" id="hydrant">
				</span>
                        <input type="text" class="form-control" disabled value="有无室外消火栓供水泵">
                    </div>
                </div>
            </div>

                <div class="row" style="margin-bottom:10px">
                    <div class="col-lg-4">
                        <div class="input-group">
					<span class="input-group-addon">
						<input type="checkbox" name="{{ module_list.3.module_en_name }}"
                               id="{{ module_list.3.module_en_name }}">
					</span>
                            <input type="text" class="form-control" disabled value="{{ module_list.3.module_name }}">
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="input-group">
					<span class="input-group-addon">
						<input type="checkbox" name="{{ module_list.4.module_en_name }}"
                               id="{{ module_list.4.module_en_name }}" >
					</span>
                            <input type="text" class="form-control" disabled value="{{ module_list.4.module_name }}">
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="input-group">
					<span class="input-group-addon">
						<input type="checkbox" name="{{ module_list.5.module_en_name }}"
                               id="{{ module_list.5.module_en_name }}" >
					</span>
                            <input type="text" class="form-control" disabled value="{{ module_list.5.module_name }}">
                        </div>
                    </div>
                </div>
                <div class="row" style="margin-bottom:10px">
                    <div class="col-lg-4">
                        <div class="input-group">
					<span class="input-group-addon">
						<input type="checkbox" name="{{ module_list.6.module_en_name }}"
                               id="{{ module_list.6.module_en_name }}" >
					</span>
                            <input type="text" class="form-control" disabled value="{{ module_list.6.module_name }}">
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="input-group">
					<span class="input-group-addon">
						<input type="checkbox" name="{{ module_list.7.module_en_name }}"
                               id="{{ module_list.7.module_en_name }}"  >
					</span>
                            <input type="text" class="form-control" disabled value="{{ module_list.7.module_name }}">
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="input-group">
                            <span class="input-group-addon">
                                <input type="checkbox" name="{{ module_list.8.module_en_name }}"
                                       id="{{ module_list.8.module_en_name }}">
                            </span>
                            <input type="text" class="form-control" disabled value="{{ module_list.8.module_name }}">
                        </div>
                    </div>
                </div>
                <div class="row" style="margin-bottom:10px">
                    <div class="col-lg-4">
                        <div class="input-group">
					<span class="input-group-addon">
						<input type="checkbox" name="{{ module_list.9.module_en_name }}"
                               id="{{ module_list.9.module_en_name }}">
					</span>
                            <input type="text" class="form-control" disabled value="{{ module_list.9.module_name }}">
                        </div>
                    </div>
                </div>
                <input type="button" class="btn-primary" value="保存" id="submit" onclick="submit1()"/>
        </form>
    </div>
{% endblock %}

{% block extrajs %}
{{ block.super }}
    <script>
        //提交保存
        function submit1() {
            $('#submit').attr("disabled",true);
            var cntckb = $('#form').find("input:checkbox:checked").length;
            if (cntckb){
                var serializeStr = $("#form").serialize()
                var csrf = $("input[name='csrfmiddlewaretoken']").val()
                $.post("{% url 'project_add' %}", {data: serializeStr, csrfmiddlewaretoken: csrf}, function (result) {

                    if (result.msg == 'success') {
                        $.globalMessenger().post({
                        message: result.data.msg,
                        hideAfter: 6,
                        type: result.msg,
                        //showCloseButton: true
                        });
                        window.location.href = result.data.url
                    } else {
                        $('#submit').attr("disabled",false);
                        $.globalMessenger().post({
                        message: result.data,
                        hideAfter: 6,
                        type: result.msg,
                        //showCloseButton: true
                        });
                    }
                })
            }
            else{
                $('#submit').attr("disabled",false);
                $.globalMessenger().post({
                        message: '至少应选择1个模块',
                        hideAfter: 6,
                        type: 'error',
                        //showCloseButton: true
                        });
            }
        }
        window.onbeforeunload = function(event) {
            event.returnValue = "有数据未保存";
        };
    </script>

{% endblock %}